#!/usr/bin/env python
# -*- coding: utf-8 -*-
# ======================================================================
#    Copyright (C) 2006 Robert Muth <robert at muth dot org>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; version 2 of June 1991.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program in form of the file COPYING;
#    if not, write to the
#
#    Free Software Foundation, Inc. <http://www.fsf.org>
#    59 Temple Place, Suite 330,
#    Boston, MA 02111-1307  USA
# ======================================================================

"""
Unittest for song
"""
#======================================================================
# python import
import unittest

import song


class testSong(unittest.TestCase):

    def setUp(self):
        #print "before test"
        return

    def tearDown(self):
        #print "after test"
        return



    def testSerialize(self):
        filename = "Test/rumba.sng"
        drumdir = "Test"
        data = file(filename).read()
        s = song.Song()
        s.deserialize(data, drumdir)

        data1 = s.serialize(drumdir)
        s.deserialize(data1, drumdir)
        data2 = s.serialize(drumdir)
        self.assertEqual(data1, data2)

        t = song.Song()
        t.deserialize(data1, drumdir)
        data3 = t.serialize(drumdir)
        self.assertEqual(data1, data3)
        return


if __name__ == '__main__':
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(testSong))
    unittest.TextTestRunner(verbosity=2).run(suite)

